<template>
  <div class="grid">
    <div class="list">
      <div class="item" :key="index" v-for="(item, index) in gridList">
        <div class="gridItem" @click="toPage(item)">
          <img :src="item.iconSrc" alt="" />
          <span>{{ item.text }}</span>
        </div>
      </div>
    </div>
    <Footer></Footer>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import getAssetsFile from "@/plugins/pub-use";
import { useRouter } from "vue-router";

const router = useRouter();
interface IItem {
  text: string;
  iconSrc: string;
  url?: string;
}

const gridList = ref<IItem[]>([
  {
    text: "错误页面",
    iconSrc: getAssetsFile("icon/caomei.png"),
    url: "/errorPage",
  },
  {
    text: "404页面",
    iconSrc: getAssetsFile("icon/chelizi.png"),
    url: "/404",
  },
  {
    text: "示例页面",
    iconSrc: getAssetsFile("icon/gouqi.png"),
    url: "/demo",
  },
  {
    text: "axios",
    iconSrc: getAssetsFile("icon/huangtao.png"),
    url: "/axios",
  },
  {
    text: "pinia",
    iconSrc: getAssetsFile("icon/lanmei.png"),
    url: "/pinia",
  },
  {
    text: "防抖&节流",
    iconSrc: getAssetsFile("icon/mangguo.png"),
    url: "/loadash",
  },
  {
    text: "hooks",
    iconSrc: getAssetsFile("icon/niuyouguo.png"),
    url: "/hooks",
  },
  {
    text: "敬请期待",
    iconSrc: getAssetsFile("icon/pingguo.png"),
  },
  {
    text: "敬请期待",
    iconSrc: getAssetsFile("icon/pipa.png"),
  },
]);
const toPage = (item: IItem) => {
  item.url && router.push(item.url);
};
</script>

<style lang="scss" scoped>
.grid {
  min-height: 100%;
  display: flex;
  flex-direction: column;

  .list {
    flex: 1;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 20px;
    box-sizing: border-box;
  }
  .item {
    width: 90px;
    height: 80px;
    padding: 5px;
    font-size: 12px;
  }
  .gridItem {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    padding-top: 8px;
    background-color: rgba(96, 159, 26, 0.05);
    border: 1px solid rgb(96, 159, 26, 0.3);
    box-shadow: 2px 2px 4px rgba(96, 159, 26, 0.2);
    border-radius: 10px;
    img {
      width: 48px;
    }

    span {
      line-height: 30px;
      text-align: center;
      white-space: nowrap;
    }
  }
}
</style>
